/*按钮状态：

 1.点classify页面按钮后先显示load data页面。load data页面按钮变成绿色。
 其他页面按钮都是灰色。并且不可点击
 2.load按钮点击后跳转到perliminary classify页面. perliminary classify页面按钮变成绿色，load data按钮变成白色。其他按钮是灰色不可点击。
 3.点击classify按钮后跳转到summary页面。除summery之外所有的页面的按钮都变成白色可点击，summary的页面按钮呈绿色。

 4.summary页面中的all,20两个按钮点击任一，跳转到manual examination页面。
 同时summary页面里面all,20这些按钮被点击过的都要变成一种被点击后的颜色。
 */
var button_list = [];//button列表的全局变量
var icon_list = $(".icon-down");
search_button();
function change_button_status(num){
  for(var j = 0;j<3;j++){
    if(j<num){
      button_list[0].css("background-color","grey");
      button_list[j].attr("disabled",false);
    }else if(j>num){
      button_list[0].css("background-color","grey");
      button_list[j].attr("disabled",true);
    }else{
      button_list[0].css("background-color","#337ab7");
      button_list[j].attr("disabled",false);
    }
  }
}

function search_button(){
  var length = $(".list>button").length;
  for(var i = 0; i < length; i ++){
    button_list[i] = $(".list>button").eq(i);
  }
}

function init_button_status(){//初始化5个功能按钮的状态
  var len = button_list.length;
  for(var i = 0;i<len;i++){
    button_list[i].attr("disabled",true);
    button_list[i].addClass("btn-no");
  }
  button_list[0].attr("disabled",false);
  button_list[0].css("background-color","#337ab7");
}
function live_all_button(){//复活所有button

}
//新版本
var btn_status = 1;
function set_btn_status(st){
  if(st == 1){
    button_list[0].css("background-color","#337ab7");
    button_list[0].attr("disabled",false);
    button_list[1].css("background-color","lightgrey");
    button_list[1].attr("disabled",true);
    button_list[2].css("background-color","lightgrey");
    button_list[2].attr("disabled",true);
    button_list[3].css("background-color","lightgrey");
    button_list[3].attr("disabled",true);
    button_list[4].css("background-color","lightgrey");
    button_list[4].attr("disabled",true);
    btn_status = 1;
  }else if(st == 2){
    button_list[0].css("background-color","white");
    button_list[0].attr("disabled",false);
    button_list[1].css("background-color","#337ab7");
    button_list[1].attr("disabled",false);
    button_list[2].css("background-color","lightgrey");
    button_list[2].attr("disabled",true);
    button_list[3].css("background-color","lightgrey");
    button_list[3].attr("disabled",true);
    button_list[4].css("background-color","lightgrey");
    button_list[4].attr("disabled",true);
    btn_status = 2;
  }else if(st == 3){
    button_list[0].css("background-color","white");
    button_list[0].attr("disabled",false);
    button_list[1].css("background-color","white");
    button_list[1].attr("disabled",false);
    button_list[2].css("background-color","#337ab7");
    button_list[2].attr("disabled",false);
    button_list[3].css("background-color","white");
    button_list[3].attr("disabled",false);
    button_list[4].css("background-color","white");
    button_list[4].attr("disabled",false);
    btn_status = 3;
  }else if(st == 4){
    button_list[0].css("background-color","white");
    button_list[0].attr("disabled",false);
    button_list[1].css("background-color","white");
    button_list[1].attr("disabled",false);
    button_list[2].css("background-color","white");
    button_list[2].attr("disabled",false);
    button_list[3].css("background-color","#337ab7");
    button_list[3].attr("disabled",false);
    button_list[4].css("background-color","white");
    button_list[4].attr("disabled",false);
    //btn_status = 4;
  }else if(st == 5){
    button_list[0].css("background-color","white");
    button_list[0].attr("disabled",false);
    button_list[1].css("background-color","white");
    button_list[1].attr("disabled",false);
    button_list[2].css("background-color","white");
    button_list[2].attr("disabled",false);
    button_list[3].css("background-color","white");
    button_list[3].attr("disabled",false);
    button_list[4].css("background-color","#337ab7");
    button_list[4].attr("disabled",false);
    //btn_status = 5;
  }
}
function change_btn_color(num){
  for(var i = 0;i< 5;i++){
    if(i != num){
      if(btn_status == 1){

      }else if(btn_status == 2){
        button_list[0].css("background-color","white");
        button_list[1].css("background-color","white");
      }else if(btn_status == 3){
        button_list[i].css("background-color","white");
      }
    }
  }
  for(var j = 0;j<icon_list.length;j++){
    if(j<num){
      icon_list.eq(j).css("background-position","0 0");
    }else{
      icon_list.eq(j).css("background-position","-31px 0");
    }
  }
  button_list[num].css("background-color","#337ab7");
}

function set_icon_status(num){//设置向下箭头状态
  if(num == 1){
    icon_list.css("background-position","-31px 0");
  }else if(num == 2){
    icon_list.eq(0).css("background-position","0 0");
    icon_list.eq(1).css("background-position","-31px 0");
    icon_list.eq(2).css("background-position","-31px 0");
    icon_list.eq(3).css("background-position","-31px 0");
  }else if(num == 3){
    icon_list.eq(0).css("background-position","0 0");
    icon_list.eq(1).css("background-position","0 0");
    icon_list.eq(2).css("background-position","-31px 0");
    icon_list.eq(3).css("background-position","-31px 0");
  }
}
